import React, { Component } from 'react';
import {HashRouter as Router, Route ,Switch} from "react-router-dom";
import Cover from './Cover';
import Navigation from './Navigation';

class Entrance extends Component{
    constructor(props){
        super(props);
        this.state = {
            height:document.documentElement.clientHeight,
        };
    }
    componentDidMount(){
        window.addEventListener('resize',this.handleHeigt.bind(this))
    }

    componentWillUnmount(){
        window.removeEventListener('resize',this.handleHeigt.bind(this))
    }

    handleHeigt = ()=>{
        const screenHeight = document.documentElement.clientHeight;
        const screenWidth = document.documentElement.clientWidth;
        let height = `${screenHeight}px`;
        let width = `${screenWidth}px`
        this.setState({
            height,width
        })
    }

    render(){
        return(
            <div>
                <Router>
                    <div className='root' style={{overflow:'auto',width:this.state.width ,height:this.state.height,minHeight:'600px',minWidth:'250px'}}>
                        <Switch>
                            <Route exact path="/" component={Cover}/>
                            <Route component={Navigation}/>
                            {/* <Route component={CommonEntrance}/>
                            <Route component={AuthEntrance}/> */}
                        </Switch>
                    </div>
                </Router>
            </div>
        )
    }
}
export default Entrance;

